﻿using System;
using CodeBadger.GasMileage.Models;

namespace CodeBadger.GasMileage.ViewModels
{
    public class AddEditViewModel : ViewModel
    {
        public AddEditViewModel()
        {
            Entry = new NotebookEntry {Date = DateTime.Now.Date};
        }

        public NotebookEntry Entry { get; set; }

        public void Save()
        {
            if (Entry.Id != Guid.Empty) return;
            for (int i = 0; i < 200; i++)
            {
                Entry.Id = Guid.NewGuid();
                CurrentApp.UserNotebook.Add(Entry);
            }

            //Entry.Id = Guid.NewGuid();
            //CurrentApp.UserNotebook.Add(Entry);
        }

        public void Delete()
        {
            CurrentApp.UserNotebook.Remove(Entry);
        }

        public void LoadById(Guid guid)
        {
            Entry = CurrentApp.UserNotebook.FindById(guid);
            NotifyPropertyChanged("Entry");
        }
    }
}
